﻿using System.Windows.Forms;
using ComputerVision.BaseForm;
using ComputerVision.Data;
using ComputerVision.Services;
using Autofac;
using ComputerVision.Data.Models;
using System;
using System.Linq;
using System.Collections.Generic;

namespace ComputerVision.LoaiCoSoForm
{
    public partial class frmBaoCaoBieuDo : frmList
    {
        private IService<PhieuDieuTraCoSo> _phieuDieuTraCoSo;        

        public frmBaoCaoBieuDo()
        {
            InitializeComponent();            

            _phieuDieuTraCoSo = Program.Container.Resolve<IService<PhieuDieuTraCoSo>>();
        }

        private void GenerateReport(object sender, System.EventArgs e)
        {          
            QuanLyThongTinCoSoContext context = new QuanLyThongTinCoSoContext();
            var data = context.Database.SqlQuery<BieuDoCoSo>("BieuDoCoSo").ToList();

            if (data.Count > 0)
            {
                foreach (var item in data)
                {
                    chart.Series[0].Points.AddXY(item.Ten, item.TaiSan);
                    chart.Series[1].Points.AddXY(item.Ten, item.Chet);
                }
            }
        }
    }
}
